package com.stupro.cjlu.manager;

import com.stupro.cjlu.dao.CourseDAO;
import com.stupro.cjlu.dao.TeacherDAO;
import com.stupro.cjlu.entity.Course;
import com.stupro.cjlu.entity.Teacher;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CourseManager {
    private final CourseDAO courseDAO;
    private final TeacherDAO teacherDAO;

    public CourseManager(CourseDAO courseDAO, TeacherDAO teacherDAO) {
        this.courseDAO = courseDAO;
        this.teacherDAO = teacherDAO;
    }

    public int create(Course entity) {
        return courseDAO.insert(entity);
    }

    public Course get(Integer id) {
        return courseDAO.get(id);
    }

    public Teacher getTeacherById(Integer teacherId) {
        return teacherDAO.get(teacherId);
    }

    public Integer getPageCount(Integer teacherId, String name) {
        int count = courseDAO.count(teacherId, name);
        //return calcPageCount(count, CourseDAO.PAGE_SIZE);
        return count;
    }
}
